var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var a,
    i = t("Const"),
    s = t("Sounds"),
    c = t("CPBIcon"),
    l = t("Platforms"),
    u = t("TableRules"),
    p = t("ConfS"),
    f = cc._decorator,
    d = f.ccclass,
    h =
        (f.property,
        (function (t) {
            function e() {
                return (null !== t && t.apply(this, arguments)) || this;
            }
            return (
                n(e, t),
                (e.prototype.init = function (t, e, o) {
                    var n = this;
                    (this.w = t),
                        (this.h = e),
                        (a = o),
                        (this.area = this.node.getChildByName("area")),
                        (this.container = this.node.getChildByName("container")),
                        (this.scrollView = this.container.getChildByName("scrollView").getComponent(cc.ScrollView)),
                        (this.scrollView.node.height = this.scrollView.node.getChildByName("view").height =
                            i.default.stageHei),
                        (this._container = this.scrollView.node.getChildByName("view").getChildByName("container")),
                        (this.lachu1 = this.container.getChildByName("lachu1")),
                        (this._exit = this.container.getChildByName("exit")),
                        (this.exit = this._exit.getChildByName("exit")),
                        (this.container.width = i.default.stageWid),
                        (this.container.height = i.default.stageHei),
                        this.lachu1.on(cc.Node.EventType.TOUCH_END, function () {
                            s.Sounds.playFX("点击"), n.show();
                        }),
                        this.area.on(cc.Node.EventType.TOUCH_END, function () {
                            s.Sounds.playFX("点击"), n.hide();
                        }),
                        this.exit.on(cc.Node.EventType.TOUCH_END, function () {
                            s.Sounds.playFX("点击"), n.hide();
                        }),
                        (this.area.active = !1),
                        (this.lachu1.active = !1),
                        (this.scrollView.node.active = !1),
                        (this._exit.active = !1),
                        (this.node.active = !0),
                        this.向下滚();
                }),
                (e.prototype.autoShow = function () {
                    this.scrollView.node.active || (this.show(), l.default.随机跳一个CPA());
                }),
                (e.prototype.refresh = function () {
                    var t = l.default.platformCtrl.获取n个重复随机CPB(this.w * this.h * 2);
                    if (!t)
                        return (
                            l.default.delays.clear("waterfall"), (l.default.waterfall = null), void this.node.destroy()
                        );
                    this._container.destroyAllChildren();
                    for (var e = -1, o = 0, n = 0, r = t; n < r.length; n++) {
                        var i = r[n];
                        ++e >= this.w && ((e = 0), o++);
                        var s = l.default.prefabs.instantiate("CPBIcon3").getComponent(c.default);
                        this._container.addChild(s.node),
                            (s.node.x = e * a),
                            (s.node.y = -o * a),
                            s.init(i, !0, !1, !1, null);
                    }
                    this._container.height = (o + 1) * a + 20;
                }),
                (e.prototype.show = function () {
                    this.refresh(),
                        (this.area.active = !0),
                        (this.scrollView.node.active = !0),
                        (this._exit.active = !0),
                        (this.lachu1.opacity = 0),
                        this.container.stopAllActions(),
                        this.container.runAction(
                            cc
                                .moveTo(
                                    0.6,
                                    i.default.wid0 > i.default.hei0
                                        ? (i.default.stageWid + i.default.swid) / 2
                                        : i.default.wid0,
                                    0
                                )
                                .easing(cc.easeCircleActionInOut())
                        ),
                        u.TableRules.pause(),
                        cc.Canvas.instance.node.emit("弹出");
                }),
                (e.prototype.hide = function () {
                    var t = this;
                    this.container.stopAllActions(),
                        this.container.runAction(
                            cc.sequence(
                                cc.moveTo(0.4, 0, 0).easing(cc.easeCircleActionInOut()),
                                cc.callFunc(function () {
                                    (t.area.active = !1),
                                        (t.scrollView.node.active = !1),
                                        (t._exit.active = !1),
                                        (t.lachu1.opacity = 255),
                                        u.TableRules.resume(),
                                        cc.Canvas.instance.node.emit("弹出");
                                })
                            )
                        );
                }),
                (e.prototype.向下滚 = function () {
                    var t = this;
                    this.scrollView.scrollToPercentVertical(1, 8, !1),
                        l.default.delays.delay({
                            time: p.DatasManager.瀑布流来回一次时间 / 2,
                            action: function () {
                                t.向上滚();
                            },
                            group: "waterfall"
                        });
                }),
                (e.prototype.向上滚 = function () {
                    var t = this;
                    this.scrollView.scrollToPercentVertical(0, 8, !1),
                        l.default.delays.delay({
                            time: p.DatasManager.瀑布流来回一次时间 / 2,
                            action: function () {
                                t.向下滚();
                            },
                            group: "waterfall"
                        });
                }),
                (e = r([d], e))
            );
        })(cc.Component));
o.default = h;
